if(isSelected())
{
if(m_dir == Right && (event->buttons() & Qt::RightButton)){
double ang = 0;
double x = m_cenPt.x()-m_movePoint.x();
double y = m_cenPt.y()-m_movePoint.y();
if(abs(x) > 0.001){
if(x < 0){
ang = atan(y/x)*180/PI; //通过弧度求角度
if(ang < 0)
ang = atan(y/x)*180/PI 360; //通过弧度求角度
}
else
ang = atan(y/x)*180/PI 180; //通过弧度求角度
}
double oldAng = rotation();
setTransformOriginPoint(m_cenPt); //设置旋转中心
setRotation(ang oldAng); //旋转角度,如果不加oldAng,则角度旋转不对
}
else if(m_selectMod == SizeMode){
resizeTo(m_dir,event->scenePos());
}
else
QGraphicsItem::mouseMoveEvent(event); //如果在拉伸时也调用,则会位置设置不对
}
评论